<?php
/***
 *Powered by b2bbuilder
 *Copright http://www.b2b-builder.com
 *Auter:Brad zhang
 *Date:2008-11-7
 *Des:产品类别页面，已做缓存处理
 */
//=============================================
$display_cat=array(1000,1005,1003,1007,1001);
foreach($display_cat as $key=>$v)
{
	//--------推荐产品------------
	
	$sql="select id,pname,pic,price from ".PRO."  where  statu=2 and LOCATE($v,catid)=1 order by uptime desc limit 0,6";
	$db->query($sql);
	$cat_pro[$key]['rec_pro']=$db->getRows();
	
	//--------最新产品------------
	
	$sql="select id,pname,pic,price from ".PRO." where statu=2 and LOCATE($v,catid)=1 order by uptime desc limit 0,5";
	$db->query($sql);
	$cat_pro[$key]['new_pro']=$db->getRows();
	
	//--------类别名--------------
	$sql="select brand,cat,catid from ".PCAT." where catid='$v'";
	$db->query($sql);
	$cata=$db->fetchRow();
	$cat_pro[$key]['name']=$cata['cat'];
	//--------类别下面的品牌-------
	if(!empty($cata['brand']))
	{
		$brand_id=$cata['brand'];
		$sql="select id,name,pic from ".BRAND." where 1 and id in($brand_id)";
		$db->query($sql);
		$cat_pro[$key]['brand']=$db->getRows();
	}
	//--------类别下面的子分类------
	$s=$v."00";
	$b=$v."99";
	$sql="select * from ".PCAT." where catid>$s and catid<$b order by nums asc,char_index asc";
	$db->query($sql);
	$cat_pro[$key]['sub_cat']=$db->getRows();
	//------------------------------
	$cat_pro[$key]['catid']=$v;
}
$tpl->assign("cat_pro",$cat_pro);
$tpl->assign("current","product");
include_once("footer.php");
//=============================================
$out=tplfetch("products_index.htm",NULL,true);
?>